﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ET.Entity;
using ET.DataAccess;

public partial class Backend_Report : System.Web.UI.Page
{
    DaServiceTracking daServiceTracking = new DaServiceTracking();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.QueryString["userid"] != null && !string.IsNullOrEmpty(Request.QueryString["userid"].ToString()))
            {
                List<EtServiceTracking> serviceTrackingSet =
                    daServiceTracking.GetServiceTrackingByUserId(Request.QueryString["userid"].ToString());
                List<EtServiceTracking> serviceTrackingWithDurationSet = serviceTrackingSet;
                for (int i = 0; i < serviceTrackingSet.Count; i++)
                {
                    if (i + 1 < serviceTrackingSet.Count)
                    {
                        serviceTrackingSet[i].Duration =
                            (serviceTrackingSet[i].RegisterTime - serviceTrackingSet[i + 1].RegisterTime).ToString(@"dd\.hh\:mm\:ss");
                    }
                    else
                    {
                        serviceTrackingSet[i].Duration =
                               (serviceTrackingSet[i].RegisterTime - serviceTrackingSet[i].RegisterTime).ToString(@"dd\.hh\:mm\:ss");
                    }
                }
                rpt.DataSource = serviceTrackingWithDurationSet;
                rpt.DataBind();
            }
        }
    }
}